import request from '@/config/axios'

// 入库单主 VO
export interface StockInVO {
  id: number // 主键
  title: string // 入库单标题
  stockInNo: string // 入库单号
  purchaseOrderId: number // 采购单ID
  supplier: string // 商家
  remarks: string // 备注
  creatorName: string // 创建者
  updaterName: string // 更新者
}

// 入库单主 API
export const StockInApi = {
  // 查询入库单主分页
  getStockInPage: async (params: any) => {
    return await request.get({ url: `/oa/stock-in/page`, params })
  },

  // 查询入库单主详情
  getStockIn: async (id: number) => {
    return await request.get({ url: `/oa/stock-in/get?id=` + id })
  },

  // 新增入库单主
  createStockIn: async (data: StockInVO) => {
    return await request.post({ url: `/oa/stock-in/create`, data })
  },

  // 修改入库单主
  updateStockIn: async (data: StockInVO) => {
    return await request.put({ url: `/oa/stock-in/update`, data })
  },

  // 删除入库单主
  deleteStockIn: async (id: number) => {
    return await request.delete({ url: `/oa/stock-in/delete?id=` + id })
  },

  // 导出入库单主 Excel
  exportStockIn: async (params) => {
    return await request.download({ url: `/oa/stock-in/export-excel`, params })
  },
}



// 入库单明细 VO
export interface StockInItemVO {
  id: number // 主键
  stockInId: number // 入库单ID
  materialId: number // 物料ID
  materialCode: string // 物料编码
  materialName: string // 物料名称
  materialType: number // 物料类型
  unitType: number // 单位
  quantity: number // 数量
  remarks: string // 备注
  creatorName: string // 创建者
  updaterName: string // 更新者
}

// 入库单明细 API
export const StockInItemApi = {
  // 查询入库单明细分页
  getStockInItemPage: async (params: any) => {
    return await request.get({ url: `/oa/stock-in-item/page`, params })
  },

  // 查询入库单明细详情
  getStockInItem: async (id: number) => {
    return await request.get({ url: `/oa/stock-in-item/get?id=` + id })
  },

  // 新增入库单明细
  createStockInItem: async (data: StockInItemVO) => {
    return await request.post({ url: `/oa/stock-in-item/create`, data })
  },

  // 修改入库单明细
  updateStockInItem: async (data: StockInItemVO) => {
    return await request.put({ url: `/oa/stock-in-item/update`, data })
  },

  // 删除入库单明细
  deleteStockInItem: async (id: number) => {
    return await request.delete({ url: `/oa/stock-in-item/delete?id=` + id })
  },

  // 导出入库单明细 Excel
  exportStockInItem: async (params) => {
    return await request.download({ url: `/oa/stock-in-item/export-excel`, params })
  },
}
